  <template> 
	<div class="JNPF-common-layout">
		<div class="JNPF-common-layout-center">
			<el-row class="JNPF-common-search-box" :gutter="16">
				<el-form @submit.native.prevent>
					<el-col :span="6">
						<el-form-item label="排查状态">
							<el-select v-model="query.pczt" placeholder="排查状态" clearable >
								<el-option v-for="(item, index) in pcztOptions" :key="index" :label="item.fullName" :value="item.id"  />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="风险点类型">
							<el-select v-model="query.fxdlx" placeholder="风险点类型" clearable >
								<el-option v-for="(item, index) in fxdlxOptions" :key="index" :label="item.fullName" :value="item.id"  />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="6">
					<el-form-item>
						<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
						<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
					</el-form-item>
					</el-col>
				</el-form>
			</el-row>
			<div class="JNPF-common-layout-main JNPF-flex-main">
				<div class="JNPF-common-head">
					<div>
						<!-- <el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()">
							新增
						</el-button> -->
                        <el-button type="text" @click="goFanHui()">
							返回
						</el-button>
					</div>
					<div class="JNPF-common-head-right">
						<el-tooltip effect="dark" content="刷新" placement="top">
							<el-link icon="icon-ym icon-ym-Refresh JNPF-common-head-icon" :underline="false"  @click="reset()" />
						</el-tooltip>
						<screenfull :isContainer="true" />
						<el-tooltip effect="dark" content="列设置" placement="top">
							<el-link icon="icon-ym icon-ym-options JNPF-common-head-icon" :underline="false" />
						</el-tooltip>
					</div>
				</div>
				<JNPF-table v-loading="listLoading" :data="list">
					<el-table-column label="风险点"  prop="fxd" algin="left">
						<template slot-scope="scope">{{ scope.row.fxd | dynamicText(fxdOptions) }}</template>
					</el-table-column>
					<el-table-column label="风险点类型"  prop="fxdlx" algin="left">
						<template slot-scope="scope">{{ scope.row.fxdlx | dynamicText(fxdlxOptions) }}</template>
					</el-table-column>
					<!-- <el-table-column label="排查人"  prop="pcr" algin="left">
						<template slot-scope="scope">{{ scope.row.pcr | dynamicText(pcrOptions) }}</template>
					</el-table-column> -->
                    <el-table-column prop="pcrname" label="排查人" align="left" />
					<el-table-column label="排查状态"  prop="pczt" algin="left">
						<template slot-scope="scope">{{ scope.row.pczt | dynamicText(pcztOptions) }}</template>
					</el-table-column>
					<!-- <el-table-column prop="pcjhid" label="排查计划ID" align="left" /> -->
					<el-table-column label="操作" fixed="right" width="150">
						<template slot-scope="scope">
							<!-- <el-button type="text" @click="addOrUpdateHandle(scope.row.id)" >
								编辑
							</el-button>
							<el-button type="text" @click="handleDel(scope.row.id)" class="JNPF-table-delBtn">
								删除
							</el-button>
							<el-button type="text" @click="addOrUpdateHandle(scope.row.id,true)" >
								详情
							</el-button> -->
                            <el-button type="text" v-if="scope.row.pczt == '待排查'" @click="addDpc(scope.row.id,scope.row.fxdlx)" >
								排查
							</el-button>
                            <el-button type="text" v-if="scope.row.pczt == '已排查'" @click="addYpc(scope.row.id,scope.row.fxdlx)" >
								查看
							</el-button>
						</template>
					</el-table-column>
				</JNPF-table>
				<!-- <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" /> -->
				<pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="initData" />
			</div>
		</div>
		<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh1="refresh1" />
        <IndexJcx v-if="indexJcx" ref="IndexJcx" @refreshIndexJcx="refreshIndexJcx" />
	</div>

</template> 
  <script>
    import request from '@/utils/request'
    import {getDictionaryDataSelector} from '@/api/systemData/dictionary'
    import JNPFForm from './FormFxd'
    import IndexJcx from './indexJcx'
    import {previewDataInterface} from '@/api/systemData/dataInterface'

    export default {
        components: {JNPFForm,IndexJcx},
        data() {
            return {
                indexJcx:false,
                    showAll: false,
                query: {
					// pczt:'待排查',
					pczt:'',
					fxdlx:undefined,
                    pcjhid:''
                },
                defaultProps: {
                    children: 'children',
                    label: 'fullName'
                },
                list: [],
                listLoading: true,
                total: 0,
                listQuery: {
					// currentPage: 1,
					// pageSize: 20,
                    page: 1,
					limit: 20,

                    sort: "desc",
                    sidx: "",
                },
                formVisible: false,
                columnList: [
					{prop: 'fxd', label: '风险点'},
					{prop: 'fxdlx', label: '风险点类型'},
					{prop: 'pcr', label: '排查人'},
					{prop: 'pczt', label: '排查状态'},
					{prop: 'pcjhid', label: '排查计划ID'},

                ],
				// fxdOptions:[{"fullName":"选项一","id":"0"},{"fullName":"选项二","id":"1"}],
				// fxdlxOptions:[{"fullName":"选项一","id":"0"},{"fullName":"选项二","id":"1"}],
                fxdOptions:[],
                fxdlxOptions:[],
				// pcrOptions:[],
				pcztOptions:[{"fullName":"待排查","id":"待排查"},{"fullName":"已排查","id":"已排查"}],


            }
        },
        computed: {},
        created() {
        },
        methods: {
		// getpcrOptions()
		// {
		// 	previewDataInterface('8bca424f16d6448ab09e57a028853aa9').then(res => {
		// 		this.pcrOptions = res.data
		// 	})
		// },


            initData(Id) {
                this.fxdOptions = [];
                this.listLoading = true;
                this.query.pcjhid = Id
                let query = {
                    ...this.listQuery,
                    ...this.query
                };
                request({
                    url: `/api/System/pcjh/Actions/PCXM`,
                    method: 'post',
                    data: query
                }).then(res => {
                    let list = JSON.parse(res.msg);
                    let letterArr = list.data;
                    let fxdArr = [];
                    let fxdlxArr = [];
                    if(letterArr.length > 0){
                        for(let i=0;i<letterArr.length;i++){
                           fxdArr.push({"fullName":letterArr[i].fxdmc,"id":letterArr[i].fxd});
                           fxdlxArr.push({"fullName":letterArr[i].fxdlx,"id":letterArr[i].fxdlx});
                        }
                    }
                    this.fxdOptions = fxdArr;
                    this.fxdlxOptions = fxdlxArr;
                    
                    this.list = list.data;
                    this.listLoading = false
                })
            },
            handleDel(id) {
                this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
                    type: 'warning'
                }).then(() => {
                    request({
                        url: `/api/System/pcjhfxd/${id}`,
                        method: 'DELETE'
                    }).then(res => {
                        this.$message({
                            type: 'success',
                            message: res.msg,
                            onClose: () => {
                                this.initData(this.query.pcjhid)
                            }
                        });
                    })
                }).catch(() => {
                });
            },
            addOrUpdateHandle(id,isDetail) {
                this.formVisible = true
                this.$nextTick(() => {
                    this.$refs.JNPFForm.init(id,isDetail)
                })
            },
            download(data) {
                let query = {...data, ...this.listQuery, ...this.query}
                request({
                    url: `/api/System/pcjhfxd/Actions/Export`,
                    method: 'POST',
                    data: query
                }).then(res => {
                    if (!res.data.url) return
                    window.location.href = this.define.comUrl + res.data.url
                    this.$refs.ExportBox.visible = false
                })
            },
            search() {
                this.listQuery = {
					// currentPage: 1,
					// pageSize: 20,
                    page: 1,
					limit: 20,

                    sort: "desc",
                    sidx: "",
                }
                this.initData(this.query.pcjhid)
            },
            refresh1(isrRefresh) {
                this.formVisible = false
                if (isrRefresh) this.reset()
            },
            refreshIndexJcx(isrRefresh){
				this.indexJcx = false;
				// if (isrRefresh) this.reset()
                this.reset()
			},
            reset() {
                for (let key in this.query) {
                    if(key !== 'pcjhid'){
                        this.query[key] = undefined
                    }
                }
                this.listQuery = {
					// currentPage: 1,
					// pageSize: 20,
                    page: 1,
					limit: 20,

                    sort: "desc",
                    sidx: "",
                }
                this.initData(this.query.pcjhid)
            },
            goFanHui(){
                this.$emit("refreshIndexFxd", '');
            },
            addDpc(id,fxdlx){
                this.indexJcx = true
                this.$nextTick(() => {
                    this.$refs.IndexJcx.initData(id,fxdlx)
                })
            },
            addYpc(id,fxdlx){
                this.indexJcx = true
                this.$nextTick(() => {
                    this.$refs.IndexJcx.initData(id,fxdlx)
                }) 
            }
        }
    }
</script>